package template.course;

public abstract class ACourse {

	protected final void makeCourse() {
		this.makePPT();
		this.makeVideo();
		if (needWriteArticle()) {
			this.writeArticle();
		}
		this.packageCourse();
	}

	final void makePPT() {
		System.out.println("1. 制作PPT");
	}

	final void makeVideo() {
		System.out.println("2. 制作视频");
	}

	final void writeArticle() {
		System.out.println("3. 编写课程笔记");
	}

	// 钩子方法
	protected boolean needWriteArticle() {
		return false;
	}

	abstract void packageCourse();

}

class JavaCourse extends ACourse {

	@Override
	void packageCourse() {
		System.out.println("制作Java课程");
	}

	@Override
	protected boolean needWriteArticle() {
		return true;
	}
}

class FECourse extends ACourse {

	private boolean needWriteArticleFlag = false;

	@Override
	void packageCourse() {
		System.out.println("4.1 提供课程的前端代码");
		System.out.println("4.2 提供课程的图片等多媒体素材");
	}

	public FECourse(boolean needWriteArticleFlag) {
		this.needWriteArticleFlag = needWriteArticleFlag;
	}

	@Override
	protected boolean needWriteArticle() {
		return this.needWriteArticleFlag;
	}
}
